package logic

import (
	"context"
	"fmt"
	"math/rand/v2"

	"gozerox/rpc/internal/svc"
	"gozerox/rpc/limitx"

	"github.com/zeromicro/go-zero/core/logx"
)

type SingleLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSingleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SingleLogic {
	return &SingleLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *SingleLogic) Single(in *limitx.LoginRequest) (*limitx.LoginResponse, error) {
	// todo: add your logic here and delete this line

	fmt.Println("single", l.svcCtx.Config.ListenOn, in)
	return &limitx.LoginResponse{
		AccessToken: "AccessToken",
		ExpiresIn:   rand.Int32N(10) + 1,
	}, nil
}
func (l *SingleLogic) local() {

	// 执行你的代码 .....
}
